<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
                <link rel="stylesheet" href="bootstrap-3.1.1-dist/css/bootstrap.min.css">

<!-- Optional theme -->
<link rel="stylesheet" href="bootstrap-3.1.1-dist/css/bootstrap-theme.css">

<!-- Latest compiled and minified JavaScript -->
<script src="bootstrap-3.1.1-dist/js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/jquery-1.2.3.pack.js"></script>
<script type="text/javascript" src="js/jquery.idTabs.min.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/redmond/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
  
  <script>
       
       $(function(){
           
           //esconder as menssagens de erros
           $("#erro").hide();
           $("#senhaincorreta").hide();
           
           //verificando codigo
           $("#cod").change(function(){
               
               var codigo_val = $("#cod").val();
            //   alert("functio(asdsd)");
               
               $.post("verificarCodigo.php", {codigo:codigo_val},function(valor){
                    // alert("functio(asdsd)"+valor);
                   if(valor == 1){
                       
                       
                        $("#erro").fadeOut(500);
                       
                   }else if(valor != 1){
                       
                         //$("#erro").hide(200);
                         $("#erro").fadeIn(500);
                  
                   }
                   
               });
              
               
           });
           
           //validando senha
           
           $("#senha_cofirma").change(function(){
               
               var senha1 = $("#senha").val();
               var senha_confirma = $("#senha_cofirma").val();
               
               if(senha1 != senha_confirma){
                   
                   $("#senhaincorreta").fadeIn(500);
                   
               }else{
                   
                   $("#senhaincorreta").fadeOut(500);
               }
               
           });
           
           
       });
  
  
  
  
  
  </script>
  
  
<style>
        body {
  padding-top: 40px;
  padding-bottom: 40px;
  background-color: #eee;
}
    
#h{
    
    background-color: #868687;
    height: 0.9px;
    
}
</style>
    </head>
    <body>
        <?php
        // put your code here
            require_once 'conecta.php';
        include "varificarCodigo.php";
        
        ?>
        	  <div class="container">

<div class="row">
    <div class="col-xs-12 col-sm-8 col-md-6 col-sm-offset-2 col-md-offset-3">
        <form role="form" method="post" action="validarCadastro.php">
                    
			<h2>Por favor Cadastre-se <small> É gratuito e sempre será.</small></h2>
			<hr class="colorgraph">
			<div class="row">
				<div class="col-xs-6 col-sm-6 col-md-6">
					<div class="form-group">
                        <input type="text" name="nome" id="first_name" class="form-control input-lg" placeholder="Name" tabindex="1">
					</div>
				</div>
				<div class="col-xs-6 col-sm-6 col-md-6">
					<div class="form-group">
						<input type="text" name="sobrenome" id="last_name" class="form-control input-lg" placeholder="Sobrenome" tabindex="2">
					</div>
				</div>
			</div>
			<div class="form-group">
				<input type="text" name="username" id="display_name" class="form-control input-lg" placeholder="User name" tabindex="3">
			</div>
			<div class="form-group">
				<input type="email" name="email" id="email" class="form-control input-lg" placeholder="Email" tabindex="4">
			</div>
			<div class="row">
				<div class="col-xs-6 col-sm-6 col-md-6">
					<div class="form-group">
						<input type="password" name="senha" id="senha" class="form-control input-lg" placeholder="Password" tabindex="5">
					</div>
				</div>
				<div class="col-xs-6 col-sm-6 col-md-6">
					<div class="form-group">
						<input type="password" name="senha_confirmacao" id="senha_cofirma" class="form-control input-lg" placeholder="Confirm Password" tabindex="6">
					</div>
				</div>
                            
                            
			</div>

			<div class="row">
				<div class="col-xs-6 col-md-6">
					<div class="form-group">
						<input type="text" name="codigo" id="cod" class="form-control input-lg" placeholder="Codigo de Cadastro" tabindex="7" maxlength=3>
					</div>
				</div>
				<div class="col-xs-6  col-md-6" id="erro">
					<div class="form-group">
						   <br/>
                                                  <strong> <span class="label label-danger">Codigo invalido!!</span></strong>
					</div>
				</div>
			</div>
		

			<hr class="colorgraph" id="h">
			<div class="row">
				<div class="col-xs-6 col-md-6"><input type="submit" value="Registrar" class="btn btn-primary btn-block btn-lg" tabindex="8" name="enviar"></div>
				<div class="col-xs-6 col-md-6"><a href="index.php" class="btn btn-success btn-block btn-lg">Logar</a></div>
			</div>
                        
                        
                        <div class="row">
				<div class="col-xs-6 col-sm-6 col-md-6" id="senhaincorreta">
					<div class="form-group">
						<br/>
                                                  <strong> <span class="label label-danger">As senhas nao batem!!</span></strong>
					</div>
				</div>
			</div>
		</form>
        
        <?php 
            
               if(isset($_GET["erro"])){
                         echo "<br/><div class='alert alert-danger'<strong>".$_GET['erro']."</strong></div>";  
               }else if(isset($_GET["ok"])){

                       echo "<strong> <span class='label label-success'>".$_GET['ok']."</span></strong>"; 
                       echo "<div class='alert alert-success'<strong>".$_GET['ok']."</strong></div>";           
               }
         


         ?>
                 
                  
            
	</div>
</div>
    </body>
</html>
